#include "guish.hpp"
#ifndef FILESENDER_HPP
#define FILESENDER_HPP
#include "IOManager.hpp"
#include "RPC.hpp"

class FileSender
	:public IOUser
{
public:
	FileSender(ClientConnection *connection, int fd, StreamSender *sendStream, Job *ownerJob);
	FileSender(ClientConnection *clientConnection, int id, string path);
	~FileSender();
	
	void cancel();
	
	size_t getFileSize();
	bool isFinished();
	
	void prepareSelect(int priority, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, int *maxfd);
	void postSelect(int priority, fd_set *readfds, fd_set *writefds, fd_set *exceptfds);
	
protected:
	void closeFile();
	
	ClientConnection *clientConnection;
	StreamSender *sendStream;
	Job *ownerJob;
	int id;
	int fd;
	int64_t fileSize;
};

#endif
